import { useSelector } from 'react-redux';
import { useSearchParams } from 'umi';

const useGroupTags = () => {
  const [searchParams] = useSearchParams();
  const crowd_id = searchParams.get('crowd_id');
  const { selectedGroupTag, crowdSelectedGroupTags } = useSelector(
    (state) => state.label,
  );
  return (
    (crowd_id ? crowdSelectedGroupTags[crowd_id] : selectedGroupTag) ?? []
  ).map((v) => v);
};

export default useGroupTags;
